//帖子模型文件

//引入已经连接到 MongoDB 的 mongoose
const mongoose = require('../config/db');

//定义schema
const postSchema = new mongoose.Schema(
    {
        // title: string
        //帖子标题
                //  type: String    类型
                //  require: true   必填项
        title: {type: String, required: true},

        //帖子内容
        content: {type: String, require: true}        
    },
    {
        // timestamps: true, 会多出两个字段 createdAt    updatedAt
        timestamps: true
    }
);

// 创建模型
const postModel = mongoose.model('post', postSchema);

//暴露模型
module.exports = postModel;